package com.itheima.redbaby.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {
	private static final String NAME = "itsix.db";
	private static final int START_VERSION = 1;
//	private static final int HISTORY_VERSION = 2;
//	private static final int CURRENT_VERSION = 3;

	public DBHelper(Context context) {
		super(context, NAME, null, START_VERSION);
	}

	//分类
	public static final String TABLE_CATEGORY = "category";// 帮助
	public static final String TABLE_COL_ID = "_id";
	public static final String TABLE_COL_ISLEAF = "isleafnode";
	public static final String TABLE_COL_NAME = "name";
	public static final String TABLE_COL_PID = "parentid";
	public static final String TABLE_COL_PIC = "pic";
	public static final String TABLE_COL_TAG = "tag";

	//购物车
	public static final String TABLE_CARTTABLE = "carttable";// 帮助
	public static final String TABLE_CART_COL_ID = "product_id";
	public static final String TABLE_CART_COL_NAME = "name";
	public static final String TABLE_CART_COL_URL = "picpath";
	public static final String TABLE_CART_COL_price = "price";
	public static final String TABLE_CART_COL_score = "score";
	public static final String TABLE_CART_COL_buylimit = "buylimit";
	public static final String TABLE_CART_COL_isgift = "isgift";
	public static final String TABLE_CART_COL_productprom = "productprom";

	//订单信息
	public static final String TABLE_PAYMENTINFO_ID = "id";
	public static final String TABLE_PAYMENTINFO = "paymentinfo";// 帮助
	public static final String TABLE_PAYMENTINFO_ORDERID = "orderid";// 标题
	public static final String TABLE_PAYMENTINFO_TYPE = "type";// 标题
	
	//地址信息
	public static final String  TABLE_ADDRESS="address";
	public static final String  TABLE_ADDRESS_ID="id";
	public static final String  TABLE_ADDRESS_NAME="name";
	public static final String  TABLE_ADDRESS_PHONENUMBER="phonenumber";
	public static final String  TABLE_ADDRESS_FIXEDTEL="fixedtel";
	public static final String  TABLE_ADDRESS_PROVINCEID="provinceId";
	public static final String  TABLE_ADDRESS_CITYID="cityId";
	public static final String  TABLE_ADDRESS_AREAID="areaId";
	public static final String  TABLE_ADDRESS_AREADETAIL="areaDetail";
	public static final String  TABLE_ADDRESS_ZIPCODE="zipCode";
	public static final String  TABLE_ADDRESS_STATE="state";
	
	
	
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		// 创建本地category表
		db.execSQL("CREATE TABLE " + TABLE_CATEGORY + " (" + 
				TABLE_COL_ID + " Integer(11) primary key, " + 
				TABLE_COL_ISLEAF + " varchar(10), " + 
				TABLE_COL_NAME + " varchar(60)," +
				TABLE_COL_PID + " Integer(11)," +
				TABLE_COL_PIC + " varchar(60)," +
				TABLE_COL_TAG + " varchar(60))"
		);
		// 创建本地carttable表
		db.execSQL("CREATE TABLE " + TABLE_CARTTABLE + " (" + 
				TABLE_CART_COL_ID + " Integer(11), " + 
				TABLE_CART_COL_NAME + " varchar(10), " + 
				TABLE_CART_COL_URL + " varchar(60)," +
				TABLE_CART_COL_price + " Float," +
				TABLE_CART_COL_score + " Float," +
				TABLE_CART_COL_buylimit + " Integer(11)," +
				TABLE_CART_COL_isgift + " Integer(11)," +
				TABLE_CART_COL_productprom + " Integer(11))"
		);
		// 创建本地paymentinfo表
//		db.execSQL("CREATE TABLE " + TABLE_PAYMENTINFO + " (" + //
//				TABLE_PAYMENTINFO_ID + " int(11), " + //
//				TABLE_PAYMENTINFO_ORDERID + " varchar(20), " + //
//				TABLE_PAYMENTINFO_TYPE + " int default '3', PRIMARY KEY ('id')"
//		);
		
		//创建本地address表
		db.execSQL("CREATE TABLE " + TABLE_ADDRESS + " (" + 
				TABLE_ADDRESS_ID + " Integer primary key autoincrement, " + 
				TABLE_ADDRESS_NAME + " varchar(20), " + 
				TABLE_ADDRESS_PHONENUMBER + " varchar(20), " +
				TABLE_ADDRESS_FIXEDTEL+" varchar(20), " +
				TABLE_ADDRESS_PROVINCEID + " Integer(11)," +
				TABLE_ADDRESS_CITYID+ " Integer(11)," +
				TABLE_ADDRESS_AREAID+ " Integer(11)," +
				TABLE_ADDRESS_AREADETAIL + " varchar(200), " + 
				TABLE_ADDRESS_ZIPCODE + " varchar(20), " + 
				TABLE_ADDRESS_STATE+ " Integer(11))" 
		);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	}
}
